<?php
	if (!(function_exists('login_ex'))){
		$smarty->template_dir = $setupdata['smarty_admin_template_dir'];
		$smarty->display('admin/login.tpl');
		$mysqlclass->close_db();
		include $setupdata['core_dir']."/includes/die.php";
	}
	
	if (!isset($_GET['parent'])) $parent=NULL; else $parent=$_GET['parent'];
	if ($parent==NULL) if (!isset($_POST['parent'])) $parent=NULL; else $parent=$_POST['parent'];
 	if (!isset($_GET['act'])) $act=NULL; else $act=$_GET['act'];
	if ($act==NULL) if (!isset($_POST['act'])) $act=NULL; else $act=$_POST['act'];
	if (!isset($_GET['mod'])) $mod=NULL; else $mod=$_GET['mod'];
	if ($mod==NULL) if (!isset($_POST['mod'])) $mod=NULL; else $mod=$_POST['mod'];
	if (!isset($_GET['new_lang'])) $new_lang=NULL; else $new_lang=$_GET['new_lang'];
	if ($new_lang==NULL) if (!isset($_POST['new_lang'])) $new_lang=NULL; else $new_lang=$_POST['new_lang'];

	include($setupdata['core_dir']."/includes/setlang.php");
	$data['tree']['lng']['cur']=$lang; 

	if ($mod=="catalog"){
		if ($act == 'cop'){
			$mas = array();
			if (isset($_GET["ids"])) $mas=$_GET["ids"]; else {if (isset($_POST["ids"])) $mas=$_POST["ids"]; else unset($mas);}			
			if (isset($mas) && count($mas) > 0) {
				foreach ($mas as $val) {
					if (isset($new_lang) and (strlen($new_lang) > 0)){
						$treeclass->tree_copy($val, $parent, $_SESSION['login_user'], $new_lang);
					} else {
						$treeclass->tree_copy($val, $parent, $_SESSION['login_user'], $lang);
					}
				}
			}
		}
		if ($act == 'rem'){
			$mas = array();
			$arr_path = array();
			if (isset($_GET["ids"])) $mas=$_GET["ids"]; else {if (isset($_POST["ids"])) $mas=$_POST["ids"]; else $mas="";}
			if (isset($mas) && is_array($mas) && (count($mas) > 0)) {
				foreach ($mas as $val) {
					if ($parent <> $val){
						$arr_path = $treeclass->sqlpath($parent);
						$treeclass->tree_move($val, $parent, $_SESSION['login_user'], $arr_path);
					}
				}
			}
		}
	}	
	require ($setupdata['core_dir'].'/includes/referer.php');
?>
